home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 June / MacFormat 25.iso / Shareware City / Developers / OutOfPhase1.1 Source / OutOfPhase Folder / CompilerScanner.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-24  |  3.0 KB  |  122 lines  |  [TEXT/KAHL]

  1. /* CompilerScanner.h */
  2.  
  3. #ifndef Included_CompilerScanner_h
  4. #define Included_CompilerScanner_h
  5.  
  6. /* CompilerScanner module depends on */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11. /* TrashTracker */
  12. /* DataMunging */
  13. /* StringThing */
  14. /* Numbers */
  15. /* FixedPoint */
  16.  
  17. #include "FixedPoint.h"
  18.  
  19. /* workaround for strange CodeWarrior bug -- it doesn't like identifier TokenRec */
  20. #define TokenRec MyTRec
  21.  
  22. struct ScannerRec;
  23. typedef struct ScannerRec ScannerRec;
  24.  
  25. struct TokenRec;
  26. typedef struct TokenRec TokenRec;
  27.  
  28. /* forward */
  29. struct TrashTrackRec;
  30.  
  31. /* all blocks are allocated with TrashTracker */
  32.  
  33. /* token type */
  34. typedef enum
  35.     {
  36.         eTokenIdentifier EXECUTE(= -8438),
  37.         eTokenString,
  38.         eTokenInteger,
  39.         eTokenSingle,
  40.         eTokenDouble,
  41.         eTokenFixed,
  42.  
  43.         eTokenKeyword,
  44.  
  45.         eTokenOpenParen, /* ( */
  46.         eTokenCloseParen, /* ) */
  47.         eTokenOpenBracket, /* [ */
  48.         eTokenCloseBracket, /* ] */
  49.         eTokenColon, /* : */
  50.         eTokenSemicolon, /* ; */
  51.         eTokenComma, /* , */
  52.         eTokenColonEqual, /* := */
  53.         eTokenPlus, /* + */
  54.         eTokenMinus, /* - */
  55.         eTokenStar, /* * */
  56.         eTokenSlash, /* / */
  57.         eTokenEqual, /* = */
  58.         eTokenNotEqual, /* <> */
  59.         eTokenLessThan, /* < */
  60.         eTokenLessThanOrEqual, /* <= */
  61.         eTokenGreaterThan, /* > */
  62.         eTokenGreaterThanOrEqual, /* >= */
  63.         eTokenShiftLeft, /* << */
  64.         eTokenShiftRight, /* >> */
  65.         eTokenCircumflex, /* ^ */
  66.  
  67.         eTokenEndOfInput,
  68.  
  69.         eTokenError
  70.     } TokenTypes;
  71.  
  72. typedef enum
  73.     {
  74.         eScannerMalformedFloat EXECUTE(= -27517),
  75.         eScannerUnknownCharacter
  76.     } ScannerErrors;
  77.  
  78. /* create a scanner information record */
  79. ScannerRec*                    NewScanner(struct TrashTrackRec* TrashTracker, char* RawData);
  80.  
  81. /* add a token to the scanner.  Keyword is a null terminated statically */
  82. /* allocated string */
  83. void                                AddKeywordToScanner(ScannerRec* Scanner, char* Keyword, long Tag);
  84.  
  85. /* get the line number (starting at 1) that the scanner is on right now */
  86. long                                GetCurrentLineNumber(ScannerRec* Scanner);
  87.  
  88. /* get a token */
  89. TokenRec*                        GetNextToken(ScannerRec* Scanner);
  90.  
  91. /* push a token back onto the token stream */
  92. void                                UngetToken(ScannerRec* Scanner, TokenRec* Token);
  93.  
  94. /* get the type of a token */
  95. TokenTypes                    GetTokenType(TokenRec* Token);
  96.  
  97. /* get the string associated with an identifier */
  98. char*                                GetTokenIdentifierString(TokenRec* Token);
  99.  
  100. /* get the string associated with a string token */
  101. char*                                GetTokenStringValue(TokenRec* Token);
  102.  
  103. /* get the integer value associated with an integer token */
  104. long                                GetTokenIntegerValue(TokenRec* Token);
  105.  
  106. /* get the single precision value associated with a single float token */
  107. float                                GetTokenSingleValue(TokenRec* Token);
  108.  
  109. /* get the double precision value associated with a double float token */
  110. double                            GetTokenDoubleValue(TokenRec* Token);
  111.  
  112. /* get the fixed precision value associated with a fixed token */
  113. largefixedsigned        GetTokenFixedValue(TokenRec* Token);
  114.  
  115. /* get the tag associated with a keyword token */
  116. long                                GetTokenKeywordTag(TokenRec* Token);
  117.  
  118. /* get the error code associated with an error token */
  119. ScannerErrors                GetTokenErrorCode(TokenRec* Token);
  120.  
  121. #endif
  122.